(function() {
  var EMAIL_EXPRESSION, TomatoBreak, USER_NAME_EXPRESSION, User;
  var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
    for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
    function ctor() { this.constructor = child; }
    ctor.prototype = parent.prototype;
    child.prototype = new ctor;
    child.__super__ = parent.prototype;
    return child;
  };
  TomatoBreak = this.TomatoBreak;
  USER_NAME_EXPRESSION = /^([a-zA-Z0-9_\-])*$/;
  EMAIL_EXPRESSION = /^([0-9a-zA-Z]+[-._+&])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/;
  User = (function() {
    __extends(User, Spine.Model);
    function User() {
      User.__super__.constructor.apply(this, arguments);
    }
    User.configure('User', 'userName', 'password', 'confirm', 'email');
    User.extend(Spine.Model.Ajax);
    User.extend({
      url: function() {
        return 'user';
      }
    });
    User.prototype.validate = function() {
      var addError, errors;
      errors = [];
      addError = function(name, message) {
        var error;
        error = {
          name: name,
          messages: []
        };
        error.messages.push(message);
        return errors.push(error);
      };
      if (!this.userName) {
        addError('userName', 'User name cannot be blank.');
      } else if (!USER_NAME_EXPRESSION.test(this.userName)) {
        addError('userName', 'User name must be alphanumeric characters and \
                can only include dash or underscore.');
      }
      if (!this.password) {
        addError('password', 'Password cannot be blank.');
      }
      if (!this.confirm) {
        addError('confirm', 'Confirm password cannot be blank.');
      } else if (this.confirm !== this.password) {
        addError('confirm', 'Confirm password does not match password.');
      }
      if (!this.email) {
        addError('email', 'Email cannot be blank.');
      } else if (!EMAIL_EXPRESSION.test(this.email)) {
        addError('email', 'Invalid email format.');
      }
      if (errors.length) {
        return errors;
      }
    };
    return User;
  })();
  TomatoBreak.User = User;
}).call(this);
